/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author George
 */
@Entity
@Table(name = "DETALLE_COMPRA", catalog = "BDACCELCOM", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DetalleCompra.findAll", query = "SELECT d FROM DetalleCompra d"),
    @NamedQuery(name = "DetalleCompra.findByIdDetCompra", query = "SELECT d FROM DetalleCompra d WHERE d.idDetCompra = :idDetCompra"),
    @NamedQuery(name = "DetalleCompra.findByCantidad", query = "SELECT d FROM DetalleCompra d WHERE d.cantidad = :cantidad")})
public class DetalleCompra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "IdDetCompra")
    private Integer idDetCompra;
    @Column(name = "Cantidad")
    private Integer cantidad;
    @JoinColumn(name = "IdProducto", referencedColumnName = "IdProducto")
    @ManyToOne
    private Producto idProducto;
    @JoinColumn(name = "NroCompra", referencedColumnName = "NroCompra")
    @ManyToOne(optional = false)
    private OrdenCompra nroCompra;

    public DetalleCompra() {
    }

    public DetalleCompra(Integer idDetCompra) {
        this.idDetCompra = idDetCompra;
    }

    public Integer getIdDetCompra() {
        return idDetCompra;
    }

    public void setIdDetCompra(Integer idDetCompra) {
        this.idDetCompra = idDetCompra;
    }

    public Integer getCantidad() {
        return cantidad;
    }

    public void setCantidad(Integer cantidad) {
        this.cantidad = cantidad;
    }

    public Producto getIdProducto() {
        return idProducto;
    }

    public void setIdProducto(Producto idProducto) {
        this.idProducto = idProducto;
    }

    public OrdenCompra getNroCompra() {
        return nroCompra;
    }

    public void setNroCompra(OrdenCompra nroCompra) {
        this.nroCompra = nroCompra;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDetCompra != null ? idDetCompra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleCompra)) {
            return false;
        }
        DetalleCompra other = (DetalleCompra) object;
        if ((this.idDetCompra == null && other.idDetCompra != null) || (this.idDetCompra != null && !this.idDetCompra.equals(other.idDetCompra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.DetalleCompra[ idDetCompra=" + idDetCompra + " ]";
    }
    
}
